/**
 * Created by dujiaheng on 2016/9/5.
 */

import {mock} from '../url-config'

function toString(xmlDom) {
    var result = '';
    if (xmlDom.xml) {
        result = xmlDom.xml;
    }
    else {
        var oSerializer = new XMLSerializer();
        result = oSerializer.serializeToString(xmlDom);
    }
    if (mock())
        return result.toLocaleLowerCase()
    return result
}
function toXML(xmlstring) {
    var xmlobject;
    // for IE
    if (window.ActiveXObject) {
        xmlobject = new ActiveXObject("Microsoft.XMLDOM");
        xmlobject.async = "false";
        xmlobject.loadXML(xmlstring);
    }
    // for other browsers
    else {
        var parser = new DOMParser();
        xmlobject = parser.parseFromString(xmlstring, "text/xml");
    }
    return xmlobject;
}


export {toString,toXML}